package cn.tedu.charging.device.dao.repository;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class StationCacheRepositoryFactory {

    @Value("${station.warm.dataType}")
    private String type;

    @Autowired
    @Qualifier("GeoAndString")
    private StationCacheRepository stationCacheRepositoryGeoAndString;

    @Autowired
    @Qualifier("GeoAndGeo")
    private StationCacheRepository stationCacheRepositoryGeoAndGeo;

    @Autowired
    @Qualifier("GeoAndNoShareHash")
    private StationCacheRepository stationCacheRepositoryGeoAndNoShareHash;

    @Autowired
    @Qualifier("GeoAndShareHash")
    private StationCacheRepository stationCacheRepositoryGeoAndShareHash;


    public StationCacheRepository getStationCacheRepository() {
        if ("GeoAndString".equals(type)) { //应该写成常量
            return stationCacheRepositoryGeoAndString;
        }else if ("GeoAndGeo".equals(type)) {
            return stationCacheRepositoryGeoAndGeo;
        }else if ("GeoAndNoShareHash".equals(type)) {
            return stationCacheRepositoryGeoAndNoShareHash;
        }else if ("GeoAndShareHash".equals(type)) {
            return stationCacheRepositoryGeoAndShareHash;
        }else {
            return stationCacheRepositoryGeoAndString;
        }
    }

}
